package com.sghd.fight.module.game.service.match;

import com.sghd.fight.module.game.service.GameService;
import com.sghd.fight.module.game.service.configure.Configure;
import com.sghd.fight.module.game.service.room.IRoom;
import com.sghd.fight.module.game.service.room.Monster;
import com.sghd.fight.module.game.service.room.Player;
import com.sghd.pojo.fight.game.PlayerVo;

import java.util.Date;
import java.util.List;

/**
 * @author frank
 */
public class PveMatcher extends AbstractMathcer {

    public PveMatcher(GameService battleService, Configure configure) {
        super(battleService, configure, 3);
    }

    @Override
    public void add(PlayerVo playerInfo) {
        IRoom pveRoom = configure.build(getRoomId(), gameService, playerInfo.getLevelVo());
        if (pveRoom == null) {
            logger.debug("房间创建失败");
            return;
        }
        Date now = new Date();
        Player red = configure.transform(playerInfo, pveRoom, now);
        Monster monster = configure.transformByMonsterId(playerInfo, pveRoom, now);
        pveRoom.join(red, monster);
        if (playerInfo.getPlayerId() < 0) {
            //标记为测试房间
            pveRoom.setTest(true);
        }
        gameService.matched(pveRoom);
    }

    @Override
    public List<IRoom> doMatch(Date now) {
        return null;
    }
}
